<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数据接入与清洗 - AI 中心</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css" rel="stylesheet">
    <style>
        .nav-pills .nav-link.active {
            background-color: #0d6efd;
        }
        .preview-table {
            font-size: 0.9rem;
        }
        .preview-table th {
            background-color: #f8f9fa;
        }
    </style>
</head>
<body>
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
        <div class="container">
            <a class="navbar-brand" href="#">数据接入与清洗</a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav">
                    <li class="nav-item">
                        <a class="nav-link" href="../index.html">返回 AI 中心</a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    <div class="container-fluid">
        <div class="row">
            <!-- 左侧导航 -->
            <div class="col-md-3 col-lg-2 d-md-block bg-light sidebar collapse">
                <div class="position-sticky pt-3">
                    <ul class="nav flex-column nav-pills">
                        <li class="nav-item">
                            <a class="nav-link active" href="#data-sources" data-bs-toggle="pill">
                                <i class="bi bi-database me-2"></i>数据源管理
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#field-mapping" data-bs-toggle="pill">
                                <i class="bi bi-arrow-left-right me-2"></i>字段映射
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#data-cleaning" data-bs-toggle="pill">
                                <i class="bi bi-funnel me-2"></i>清洗规则
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#sync-settings" data-bs-toggle="pill">
                                <i class="bi bi-clock me-2"></i>同步设置
                            </a>
                        </li>
                    </ul>
                </div>
            </div>

            <!-- 右侧内容 -->
            <div class="col-md-9 ms-sm-auto col-lg-10 px-md-4">
                <div class="tab-content">
                    <!-- 数据源管理 -->
                    <div class="tab-pane fade show active" id="data-sources">
                        <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
                            <h1 class="h2">数据源管理</h1>
                            <button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addDataSourceModal">
                                <i class="bi bi-plus-lg"></i> 添加数据源
                            </button>
                        </div>

                        <div class="table-responsive">
                            <table class="table table-striped table-hover">
                                <thead>
                                    <tr>
                                        <th>数据源名称</th>
                                        <th>类型</th>
                                        <th>连接状态</th>
                                        <th>最后同步时间</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr>
                                        <td>MES 系统</td>
                                        <td>REST API</td>
                                        <td><span class="badge bg-success">已连接</span></td>
                                        <td>2024-03-10 15:30:00</td>
                                        <td>
                                            <button class="btn btn-sm btn-outline-primary">测试连接</button>
                                            <button class="btn btn-sm btn-outline-danger">删除</button>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>IoT 设备数据</td>
                                        <td>MQTT</td>
                                        <td><span class="badge bg-success">已连接</span></td>
                                        <td>2024-03-10 15:29:45</td>
                                        <td>
                                            <button class="btn btn-sm btn-outline-primary">测试连接</button>
                                            <button class="btn btn-sm btn-outline-danger">删除</button>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>

                    <!-- 字段映射 -->
                    <div class="tab-pane fade" id="field-mapping">
                        <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
                            <h1 class="h2">字段映射</h1>
                            <button class="btn btn-primary">
                                <i class="bi bi-save"></i> 保存映射
                            </button>
                        </div>

                        <div class="row">
                            <div class="col-md-6">
                                <h5>源字段</h5>
                                <div class="table-responsive">
                                    <table class="table table-sm preview-table">
                                        <thead>
                                            <tr>
                                                <th>字段名</th>
                                                <th>类型</th>
                                                <th>示例值</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <tr>
                                                <td>device_id</td>
                                                <td>string</td>
                                                <td>DEV001</td>
                                            </tr>
                                            <tr>
                                                <td>temperature</td>
                                                <td>float</td>
                                                <td>25.6</td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <h5>目标字段</h5>
                                <div class="table-responsive">
                                    <table class="table table-sm preview-table">
                                        <thead>
                                            <tr>
                                                <th>字段名</th>
                                                <th>类型</th>
                                                <th>映射规则</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <tr>
                                                <td>deviceId</td>
                                                <td>string</td>
                                                <td>device_id</td>
                                            </tr>
                                            <tr>
                                                <td>temp</td>
                                                <td>float</td>
                                                <td>temperature</td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- 清洗规则 -->
                    <div class="tab-pane fade" id="data-cleaning">
                        <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
                            <h1 class="h2">清洗规则</h1>
                            <button class="btn btn-primary">
                                <i class="bi bi-plus-lg"></i> 添加规则
                            </button>
                        </div>

                        <div class="row">
                            <div class="col-md-4">
                                <div class="card mb-3">
                                    <div class="card-body">
                                        <h5 class="card-title">缺失值处理</h5>
                                        <div class="form-check">
                                            <input class="form-check-input" type="radio" name="missingValue" id="dropMissing" checked>
                                            <label class="form-check-label" for="dropMissing">
                                                删除缺失值
                                            </label>
                                        </div>
                                        <div class="form-check">
                                            <input class="form-check-input" type="radio" name="missingValue" id="fillMissing">
                                            <label class="form-check-label" for="fillMissing">
                                                填充缺失值
                                            </label>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="card mb-3">
                                    <div class="card-body">
                                        <h5 class="card-title">异常值处理</h5>
                                        <div class="form-check">
                                            <input class="form-check-input" type="radio" name="outlier" id="removeOutlier" checked>
                                            <label class="form-check-label" for="removeOutlier">
                                                移除异常值
                                            </label>
                                        </div>
                                        <div class="form-check">
                                            <input class="form-check-input" type="radio" name="outlier" id="capOutlier">
                                            <label class="form-check-label" for="capOutlier">
                                                限制在范围内
                                            </label>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="card mb-3">
                                    <div class="card-body">
                                        <h5 class="card-title">数据标准化</h5>
                                        <div class="form-check">
                                            <input class="form-check-input" type="checkbox" id="normalize" checked>
                                            <label class="form-check-label" for="normalize">
                                                启用标准化
                                            </label>
                                        </div>
                                        <select class="form-select mt-2">
                                            <option>Z-score</option>
                                            <option>Min-Max</option>
                                            <option>Robust</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- 同步设置 -->
                    <div class="tab-pane fade" id="sync-settings">
                        <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
                            <h1 class="h2">同步设置</h1>
                            <button class="btn btn-primary">
                                <i class="bi bi-save"></i> 保存设置
                            </button>
                        </div>

                        <div class="row">
                            <div class="col-md-6">
                                <div class="card">
                                    <div class="card-body">
                                        <h5 class="card-title">同步周期</h5>
                                        <div class="mb-3">
                                            <label class="form-label">同步频率</label>
                                            <select class="form-select">
                                                <option>每分钟</option>
                                                <option>每5分钟</option>
                                                <option>每15分钟</option>
                                                <option>每小时</option>
                                                <option>每天</option>
                                            </select>
                                        </div>
                                        <div class="mb-3">
                                            <label class="form-label">开始时间</label>
                                            <input type="time" class="form-control" value="00:00">
                                        </div>
                                        <div class="mb-3">
                                            <label class="form-label">结束时间</label>
                                            <input type="time" class="form-control" value="23:59">
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="card">
                                    <div class="card-body">
                                        <h5 class="card-title">同步历史</h5>
                                        <div class="table-responsive">
                                            <table class="table table-sm">
                                                <thead>
                                                    <tr>
                                                        <th>时间</th>
                                                        <th>状态</th>
                                                        <th>记录数</th>
                                                    </tr>
                                                </thead>
                                                <tbody>
                                                    <tr>
                                                        <td>2024-03-10 15:30:00</td>
                                                        <td><span class="badge bg-success">成功</span></td>
                                                        <td>1,234</td>
                                                    </tr>
                                                    <tr>
                                                        <td>2024-03-10 15:15:00</td>
                                                        <td><span class="badge bg-success">成功</span></td>
                                                        <td>1,245</td>
                                                    </tr>
                                                </tbody>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 添加数据源模态框 -->
    <div class="modal fade" id="addDataSourceModal" tabindex="-1">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">添加数据源</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                </div>
                <div class="modal-body">
                    <form>
                        <div class="mb-3">
                            <label class="form-label">数据源名称</label>
                            <input type="text" class="form-control" required>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">数据源类型</label>
                            <select class="form-select">
                                <option>REST API</option>
                                <option>MQTT</option>
                                <option>数据库</option>
                                <option>文件</option>
                            </select>
                        </div>
                        <div class="mb-3">
                            <label class="form-label">连接配置</label>
                            <textarea class="form-control" rows="3" placeholder="请输入连接配置信息..."></textarea>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary">保存</button>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html> 